﻿using System;
using System.Collections.Generic;
using System.Data;
using Module.Common.Models;
using Module.Core.DAO;
using Module.Core.EntitiesInfo;

namespace Module.Core.BusinessLogic
{
    public class PaymentBL
	{
		/// <summary>
		/// Saves a record to the Payment table.
		/// </summary>
		public static int Insert(PaymentInfo paymentInfo)
		{
			try
			{
				return new PaymentDAO().Insert(paymentInfo);
			}
			catch (Exception ex)
			{
				throw;
			}

		}

		/// <summary>
		/// Saves a record to the Payment table.
		/// </summary>
        public static void Update(PaymentInfo paymentInfo)
		{
			try
			{
				new PaymentDAO().Update(paymentInfo);
			}
			catch (Exception ex)
			{
				throw;
			}

		}

		/// <summary>
		/// Delete a record from the Payment table.
		/// </summary>
        public static void Delete(int id)
		{
			try
			{
				new PaymentDAO().Delete(id);
			}
			catch (Exception ex)
			{
				throw;
			}

		}

		/// <summary>
		/// Selects a single record from the Payment table.
		/// </summary>
        public static PaymentInfo Select(string param,int type)
		{
			try
			{
                return new PaymentDAO().Select(param, type);
			}
			catch (Exception ex)
			{
				throw;
			}

		}

        public static DataTable DisplayTop(string codeMember,int topN,int type)
        {
            try
            {
                return new PaymentDAO().DisplayTop(codeMember,topN,type);
            }
            catch (Exception ex)
            {
                throw;
            }

        }
		/// <summary>
		/// Selects all records from the Payment table.
		/// </summary>
        public static CHRTList<PaymentInfo> SelectAll()
		{
			try
			{
				return new PaymentDAO().SelectAll();
			}
			catch (Exception ex)
			{
				throw;
			}

		}
        public static DataTable Search(string customer_name, DateTime starDatetime, DateTime endDatetime, int beginRow, int endRow, string orderByColumn)
        {
            try
            {
                return new PaymentDAO().Search(customer_name, starDatetime, endDatetime, beginRow, endRow, orderByColumn);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        public static int SelectCount(string customer_name, DateTime starDatetime, DateTime endDatetime)
        {
            try
            {
                return new PaymentDAO().SelectCount(customer_name, starDatetime, endDatetime);
            }
            catch (Exception ex)
            {
                throw;
            }

        }
        public static string Gettransaction_status(string transaction_status)
        {
            string str = "";
            if (transaction_status == "1")
                str = "Giao dịch chưa xác minh OTP";
            else if (transaction_status == "2")
                str = "Giao dịch đã xác minh OTP";
            else if (transaction_status == "4")
                str = "Giao dịch hoàn thành";
            else if (transaction_status == "5")
                str = "Giao dịch bị hủy";
            else if (transaction_status == "6")
                str = "Giao dịch bị từ chối nhận tiền";
            else if (transaction_status == "7")
                str = "Giao dịch hết hạn";
            else if (transaction_status == "8")
                str = "Giao dịch thất bại";
            else if (transaction_status == "12")
                str = "Giao dịch bị đóng băng";
            else if (transaction_status == "13")
                str = "Giao dịch bị tạm giữ (thanh toán an toàn)";
            else if (transaction_status == "X")
                str = "Các trạng thái giao dịch khác";
            return str;
        }


        public static string GetPayment_type(int payment_type)
        {
            string strMessage = "";
            if (payment_type == 1)
            {
                strMessage = "Thanh toán ngay";
            }
            else if (payment_type == 2)
            {
                strMessage = "Thanh toán an toàn";
            }

            return strMessage;
        }

	}
}
